package com.xlro.servlet;

import com.xlro.service.BookService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @ClassName AddBookServlet
 * @Description
 * @Author xlro
 * @Date 2021/5/30
 **/
@WebServlet(name = "AddBookServlet",urlPatterns = "/addBook")
public class AddBookServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("name");
        String author = req.getParameter("author");
        String library = req.getParameter("library");
        String sort = req.getParameter("sort");
        String position = req.getParameter("position");
        String status = req.getParameter("status");
        String desc = req.getParameter("desc");

        BookService bs=new BookService();
        String result = bs.addOneBook( name, author, library, sort, position, status, desc);

        req.getRequestDispatcher("./alterBookInfo.jsp?title="+"提示"+"&message="+result).forward(req,resp);

    }
}
